/**
 * Created by ex-yanjun on 14-7-01.
 */
var currentindex = 1;
var timerID;
function startAm() {
    timerID = setInterval("timer_tick()", 8000);//8000代表间隔时间设置
}
function stopAm() {
    clearInterval(timerID);
}
function timer_tick() {
    currentindex = currentindex >= 5 ? 1 : currentindex + 1;//此处的5代表幻灯片循环遍历的次数
    slide(currentindex);
}
function slide(i) {

    $(".banner-image-all").each(function(j,obj){
        var img = $(obj).attr("id");
        if(img == "img_"+i){
            $("#"+img).show();
        }else{
            $("#"+img).hide();
        }
    });
    $(".slide-bottom-title").each(function(j,obj){
        var title = $(obj).attr("id");
        if(title == "span_"+i){
            $("#"+title).show();
        }else{
            $("#"+title).hide();
        }
    });

}
$(function(){
	$("#img_1").show();
    $("#span_1").show();
    $(".banner-image-all").hide();
    $(".slide-bottom-title").hide();
    slide(1);
    //开启定时器
    startAm();
	$(".banner-pointer-one").click(function(e){
        var id = $(this).attr("id").replace('li_', '');
        slide(id);
    });
    //鼠标移动
    $('.banner-pointer-one').hover(
            function () {
                stopAm();
                $(this).click();
            },
            function () {
                startAm();
            }
    );
    var remarkNewsId=$("#remarkNewsId_1").val();
    changeNews(1,remarkNewsId);

});
function changeNews(i,id){
	$("span[id^=remarkNewsSpan_]").removeClass().addClass("down");
	$("div[id^=remarkNewsDiv_]").hide();
	$("#remarkNewsLi_1").removeClass().addClass("second");
	$("#remarkNewsLi_2").removeClass().addClass("second");
	$("#remarkNewsLi_3").removeClass().addClass("third");
	if(i==1){
		$("#remarkNewsLi_1").removeClass().addClass("first");
		$("#remarkNewsSpan_"+i).removeClass().addClass("down downshow");
		$("#remarkNewsDiv_"+i).show();
	}else if(i==2){	
		$("#remarkNewsLi_2").removeClass().addClass("first");
		$("#remarkNewsSpan_"+i).removeClass().addClass("down downshow");
		$("#remarkNewsDiv_"+i).show();
	}else{	
		$("#remarkNewsLi_3").removeClass().addClass("first");
		$("#remarkNewsSpan_"+i).removeClass().addClass("down downshow");
		$("#remarkNewsDiv_"+i).show();
	}
	//$("#xiangqing").attr("href","/tnews/newsWebDetail.html?id="+id);
	
}
function openDetails(id){
	window.location.href='/tnews/newsWebDetail.html?id='+id;
}
